<template>
  <upload :onSuccess="success" />
</template>

<script>
import upload from "@/components/upload";
export default {
  components: {
    upload
  },
  methods: {
    async success({ header, results }) {
      let info = {
        手机号: "mobile",
        姓名: "username",
        入职日期: "timeOfEntry",
        转正日期: "correctionTime",
        工号: "workNumber"
      };
      let userInfo = results.map(item => {
        let a = {};
        Object.keys(item).forEach(obj => {
          a[info[obj]] = item[obj];
        });
        return a;
      });
      try {
        await this.$api.employee.batchEmployees(userInfo);
        this.$message.success("上传数据成功");
      } catch (error) {
        this.$message.error(error);
      }
    }
  }
};
</script>

<style>
</style>